﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SWCInvoice.Enums;
using SWCInvoice.Model;

namespace SWCInvoice.Returntyps {

    /// <summary>
    /// Result of the ExtractPDF method
    /// </summary>
    public class ExtractPDFInfo : BaseInfo {
        
        #region Constanten

        /// Base object resource typ
        private const string RESOURCE_STRING = "ExtractPDF";

        #endregion

        #region Fields
        /// <summary>
        /// The virtual document structure
        /// </summary>
        private VirtualDocumentStructure _virtualDocumentStructure;

        /// <summary>
        /// Name of the linked sourcefile
        /// </summary>
        private string _fileName;

        /// <summary>
        /// Foldername of the linked sourcefile
        /// </summary>
        private string _folderName;

        /// <summary>
        /// Folderpath of the linked sourcefile
        /// </summary>
        private string _folderPath;

        /// <summary>
        /// The Pdf number of pages
        /// </summary>
        private int? _pdfNumberOfPages;

        #endregion

        #region Properties

        /// <summary>
        /// Base object resource typ
        /// </summary>        
        public override string ResourceString {
            get { return RESOURCE_STRING; }
        }

        /// <summary>
        /// The virtual document structure
        /// </summary>        
        public VirtualDocumentStructure VirtualDocumentStructure {
            get { return _virtualDocumentStructure; }
            set { _virtualDocumentStructure = value; }
        }

        /// <summary>
        /// Name of the linked sourcefile
        /// </summary>
        public string FileName {
            get { return _fileName; }
            set { _fileName = value; }
        }

        /// <summary>
        /// Foldername of the linked sourcefile
        /// </summary>
        public string FolderName {
            get { return _folderName; }
            set { _folderName = value; }
        }

        /// <summary>
        /// Foldepath of the linked sourcefile
        /// </summary>
        public string FolderPath {
            get { return _folderPath; }
            set { _folderPath = value; }
        }

        /// <summary>
        /// The Pdf number of pages
        /// </summary>
        public int? PdfNumberOfPages {
            get { return _pdfNumberOfPages; }
            set { _pdfNumberOfPages = value; }
        }

        #endregion

        #region Construcctor

        public ExtractPDFInfo(string fileName) {                                    
            MessageTyp = MessageTyp.None;

            _fileName = fileName;
        }

        #endregion
      
        #region Methods        

        public override MessageTyp SetMessageTypByObjectContent() {                        
            if (ExceptionList == null || ExceptionList.Count == 0) {
                MessageTyp = MessageTyp.Information;
            }            
            return MessageTyp;
        }

        public override Message EnrichMessageWithParameters(Message message) {            
            if (MessageTyp == MessageTyp.Information)
                message.Description = string.Format(message.Description, FileName, PdfNumberOfPages);
            
            
            if (MessageTyp == MessageTyp.Error) 
                message.Description = string.Format(message.Description, FileName, ExceptionList[0].Message);
            

            return message;
        }

        #endregion
    }
}
